﻿using ReactiveUI;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Windows;

namespace ScienceAIApp.Views.AlertView;
/// <summary>
/// Interaction logic for HistoryRecordView.xaml
/// </summary>
public partial class HistoryRecordView
{
    public HistoryRecordView()
    {
        InitializeComponent();
        this.WhenActivated(_activated);
    }

    private void _activated(CompositeDisposable disposable)
    {

        this.OneWayBind(
                ViewModel,
                vm => vm.PageCount,
                v => v.PageCount.Text)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.PageNum,
                v => v.PageNum.Text)
            .DisposeWith(disposable);

        //this.OneWayBind(
        //        ViewModel,
        //        vm => vm.IsCanPre,
        //        v => v.PreBtn.IsEnabled)
        //    .DisposeWith(disposable);

        //this.OneWayBind(
        //        ViewModel,
        //        vm => vm.IsCanNext,
        //        v => v.NextBtn.IsEnabled)
        //    .DisposeWith(disposable);

        this.BindCommand(
            ViewModel,
            vm => vm.TurnPageCommand,
            v => v.PreBtn,
            Observable.Return(false)
        ).DisposeWith(disposable);

        this.BindCommand(
            ViewModel,
            vm => vm.TurnPageCommand,
            v => v.NextBtn,
            Observable.Return(true)
        ).DisposeWith(disposable);

        this.BindCommand(
            ViewModel,
            vm => vm.ConfirmCommand,
            v => v.OkBtn
        ).DisposeWith(disposable);

        this.BindCommand(
            ViewModel,
            vm => vm.CancelCommand,
            v => v.CancelBtn
        ).DisposeWith(disposable);


        this.OneWayBind(
            ViewModel,
            vm => vm.AlertMsg,
            v => v.AlertMsg.Text
            ).DisposeWith(disposable);

        // 列表绑定
        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm1,
                v => v.Series1Host.ViewModel)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm2,
                v => v.Series2Host.ViewModel)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm3,
                v => v.Series3Host.ViewModel)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm4,
                v => v.Series4Host.ViewModel)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm5,
                v => v.Series5Host.ViewModel)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm6,
                v => v.Series6Host.ViewModel)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm7,
                v => v.Series7Host.ViewModel)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm8,
                v => v.Series8Host.ViewModel)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm9,
                v => v.Series9Host.ViewModel)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm10,
                v => v.Series10Host.ViewModel)
            .DisposeWith(disposable);

        // 列表 border 展示
        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm1.CurrentRecord,
                v => v.Series1Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm2.CurrentRecord,
                v => v.Series2Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm3.CurrentRecord,
                v => v.Series3Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm4.CurrentRecord,
                v => v.Series4Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm5.CurrentRecord,
                v => v.Series5Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm6.CurrentRecord,
                v => v.Series6Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm7.CurrentRecord,
                v => v.Series7Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm8.CurrentRecord,
                v => v.Series8Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm9.CurrentRecord,
                v => v.Series9Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.RecordVm10.CurrentRecord,
                v => v.Series10Border.Visibility,
                si => si == null ? Visibility.Collapsed : Visibility.Visible)
            .DisposeWith(disposable);

    }
}
